import axios  from "axios";
import { Toast } from "vant";
import router from '../../router/index';

const DEV_PATH = 'http://localhost:80/xxx'; // 开发环境
const UAT_PATH = 'http://localhost:80/xxx'; // 测试环境
const PRD_PATH = 'http://localhost:80/xxx'; // 生产环境

axios.defaults.baseURL = '';
axios.defaults.timeout = 10000;
// axios.defaults.withCredentials = true;
axios.defaults.headers['X-Requested-With'] = 'XMLHttpRequest';
axios.defaults.headers['token'] = localStorage.getItem('token') || '';
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';

// axios.interceptors.request.use(config => {
//   return config;
// }, error => {
//   return Promise.reject(error);
// });

axios.interceptors.response.use(res => {
  if(res.status === 200) {
    return res.data;
  }
}, error => {
  return Promise.reject(error);
});

export default axios;